import { Container } from 'inversify';
import { UserStorage } from '@2/app/core/storage/user.storage';
import { TYPES } from '@2/app/core/ioc/types';
import { UserStorageImpl } from '@2/app/core/storage/impl/user.storage.impl';
import { UserService } from '@2/app/core/services/user.service';
import { UserServiceImpl } from '@2/app/core/services/impl/user.service.impl';
import { ApiAuth } from '@2/app/core/api/api.auth';
import { ApiAuthImpl } from '@2/app/core/api/impl/api.auth.impl';
import { PermissionStorageImpl } from '@2/app/core/storage/impl/permission.storage.impl';
import { PermissionStorage } from '@2/app/core/storage/permission.storage';
import { AppStorageImpl } from '@2/app/core/storage/impl/app.storage.impl';
import { AppStorage } from '@2/app/core/storage/app.storage';
import { PermissionServiceImpl } from '@2/app/core/services/impl/permission.service.impl';
import { PermissionService } from '@2/app/core/services/permission.service';
import { ApiUser } from '@2/app/core/api/api.user';
import { ApiUserImpl } from '@2/app/core/api/impl/api.user.impl';
import { LocaleStorageImpl } from '@2/app/core/storage/impl/locale.storage.impl';
import { LocaleStorage } from '@2/app/core/storage/locale.storage';
import { ApiDept } from '@2/app/core/api/api.dept';
import { ApiDeptImpl } from '@2/app/core/api/impl/api.dept.impl';

/**
 * 容器依赖注入绑定接口实现类
 * 注意：
 *  1. 这里的绑定是将接口绑定到实现类，而不是将实现类绑定到接口。
 *  2. 接口实现类里存在调用其他接口的实现类，需注意顺序设置。
 */
const inversionContainer = new Container();
// storage
inversionContainer.bind<AppStorage>(TYPES.AppStorage).to(AppStorageImpl);
inversionContainer.bind<UserStorage>(TYPES.UserStorage).to(UserStorageImpl);
inversionContainer.bind<PermissionStorage>(TYPES.PermissionStorage).to(PermissionStorageImpl);
inversionContainer.bind<LocaleStorage>(TYPES.LocaleStorage).to(LocaleStorageImpl);
// inversionContainer.bind<MultipleTabStorage>(TYPES.MultipleTabStorage).to(MultipleTabStorageImpl);
// service
inversionContainer.bind<UserService>(TYPES.UserService).to(UserServiceImpl);
inversionContainer.bind<PermissionService>(TYPES.PermissionService).to(PermissionServiceImpl);
// api
inversionContainer.bind<ApiAuth>(TYPES.ApiAuth).to(ApiAuthImpl);
inversionContainer.bind<ApiUser>(TYPES.ApiUser).to(ApiUserImpl);
inversionContainer.bind<ApiDept>(TYPES.ApiDept).to(ApiDeptImpl);
// Subscription
export { inversionContainer };
